package com.asdhawaii.otello.board;

/**
 * Indicates the current contents of a square.
 * 
 * @author Branden Ogata
 *
 */

public enum SquareContents
{
  /**
   * Indicates an empty square.
   * 
   */
  EMPTY,
  
  /**
   * Indicates a square with a white piece.
   * 
   */
  WHITE,
  
  /**
   * Indicates a square with a black piece.
   * 
   */
  BLACK;
  
  /**
   * Returns the "opposite" of this instance.
   * 
   * @return If this SquareContents is WHITE, then returns BLACK.
   *         If this SquareContents is BLACK, then returns WHITE.
   *         Else returns EMPTY.
   *         
   */
  
  public SquareContents opposite()
  {
    switch(this)
    {
      case WHITE:
        return BLACK;
      case BLACK:
        return WHITE;
      case EMPTY:
        return EMPTY;
      default:
        return EMPTY;
    }
  }
  
  /**
   * Returns a String representation of this Square object.
   * 
   * @return "B" if this.contents is SquareContents.BLACK
   *         "W" if this.contents is SquareContents.WHITE
   *         " " if this.contents is SquareContents.EMPTY
   *         
   */
  
  @Override
  public String toString()
  {
    switch(this)
    {
      case BLACK:
        return "B";
      case WHITE:
        return "W";
      case EMPTY:
        return " ";
      default:
        return "?";
    }
  }
}
